package JAVA300.第九章容器;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * 测试collections工具类
 */
public class TestCollections {

    public static void main(String[] args) {

        List<String> list = new ArrayList<>();
        for (int i=0;i<10;i++){
            list.add("gao"+i);
        }
        System.out.println(list);

        Collections.shuffle(list);//随机排列
        System.out.println(list);

        Collections.reverse(list);//逆序排列
        System.out.println(list);

        Collections.sort(list);//生序排列--自定义用Comparable接口
        System.out.println(list);

        //Collections.binarySearch(list);//生序排列--自定义用Comparable接口
        System.out.println(Collections.binarySearch(list,"gao7"));//7--返回索引值
    }
}
